﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Index/Index_One.master" AutoEventWireup="true" CodeFile="GaugeRecordEdit.aspx.cs" Inherits="Index_Gauge_GaugeRecordEdit" %>

<%@ Register Src="~/Index/Gauge/GaugeTestItemList.ascx" TagPrefix="uc1" TagName="GaugeTestItemList" %>


<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Title" runat="Server">
    评估量表
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Info" runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Map" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Tool" runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Main_Title" runat="Server">
    <asp:Literal ID="lbl_Title" runat="server">日常生活活动能力量表（ADL）</asp:Literal>
    &nbsp;&nbsp;
    评分表&nbsp;共<asp:Literal ID="lbl_TestCount" runat="server"></asp:Literal>题
    &nbsp;&nbsp;
    满分45分
    &nbsp;&nbsp;
    得分：<asp:Literal ID="lbl_Score" runat="server"></asp:Literal>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="Main" runat="Server">
    <div style="margin: -20px;">
        <table style="width: 100%; margin: 0; padding: 0;">
            <tr>
                <td>
                    <div style="overflow: auto; height: 410px; padding: 10px;">
                        <div id="gauge_list">
                            <asp:Repeater ID="rpt_List" runat="server">
                                <ItemTemplate>
                                    <uc1:GaugeTestItemList runat="server" ID="uc_GaugeTestItemList"
                                        ItemTypeNo='<%#Eval("TestType") %>'
                                        GaugeTestId='<%#Eval("GaugeTestId") %>'
                                        GaugeTestTitle='<%#Eval("Title") %>'
                                        GridValue='<%#Eval("GridValue") %>'
                                        OrderNo='<%#Container.ItemIndex + 1 %>'
                                        AnswerValue='<%#Eval("AnswerValue")%>'
                                        GaugeRecordAnswerId='<%#Eval("GaugeRecordAnswerId")%>'
                                        TitleTexts='<%#Eval("TitleTexts")%>' />
                                </ItemTemplate>
                            </asp:Repeater>
                        </div>
                        <p style="text-align: center; padding: 20px;">
                            <asp:Button ID="btn_Save" runat="server" Text="储存" CssClass="ui-btn" OnClick="btn_Save_Click" OnClientClick="return saveAllItem()" />
                        </p>
                    </div>
                </td>
                <td style="width: 260px; vertical-align: top; padding: 10px;">
                    <div>
                        <h1>评分标准</h1>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="Footer" runat="Server">
    <script type="text/javascript">
        function saveAllItem() {
            $('#gauge_list div.gauge-item[data-typeno=RADIO]').each(function () {
                var value = '';
                $(this).find('li input[type=radio]:checked').each(function () {
                    value = $(this).val() + '\t';
                    var $text = $(this).parent().find('input[type=text]');
                    if ($text.length > 0) {
                        value += $text.val();
                    }
                });
                $(this).find('input[type=hidden]:first').val(value);
            });

            $('#gauge_list div.gauge-item[data-typeno=CHECKBOX]').each(function () {
                var value = '';
                $(this).find('li input[type=checkbox]:checked').each(function () {
                    value += $(this).val() + "\t";
                    var $text = $(this).parent().find('input[type=text]');
                    if ($text.length > 0) {
                        value += $text.val();
                    }
                    value += "\n";
                });
                $(this).find('h1 input[type=hidden]').val(value);
            });

            $('#gauge_list div.gauge-item[data-typeno=AREATEXT]').each(function () {
                var value = '';
                $(this).find('textarea').each(function () {
                    value += $(this).val();
                });
                $(this).find('input[type=hidden]:first').val(value);
            });

            //获取标题文本的值
            $('#gauge_list div.gauge-item').each(function () {
                var value = '';
                $(this).find('h1 input[type=text]').each(function () {
                    value += $(this).val() + '\t';
                });
                $(this).find('input[type=hidden]:eq(1)').val(value);
            });

            $('#gauge_list div.gauge-item[data-typeno=STEP_GRID]').each(function () {
                var value = '';
                $(this).find('li .ui-step-grid tbody tr').each(function () {
                    $(this).find('td input[type=text]').each(function (index, element) {
                        if (index > 0) {
                            value += "\t";
                        }
                        value += $(this).val();
                    });
                    value += "\n";
                });
                $(this).find('input[type=hidden]:first').val(value);
            });
            return true;
        }
    </script>
    <!--初始化-->
    <script type="text/javascript">
        $(function () {
            $('#gauge_list div.gauge-item').each(function () {
                var titletexts = $(this).find('input[type=hidden]:eq(1)').val().split('\t');
                $(this).find('h1:first input[type=text]').each(function (index, element) {
                    $(this).val(titletexts[index]);
                });
            });
        });
    </script>
</asp:Content>

